<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>问答题批阅</title>
    <link rel="stylesheet" href="/lims/layui/css/layui.css?20190817.1">
    <link rel="stylesheet" href="/lims/css/common.css">
    <link rel="stylesheet" href="/lims/css/eleTree.css">
    <script src="/lims/layui/layui.js"></script>
    <script type="text/javascript" src="/lims/layui/global.js"></script>
    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery-1.8.3.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
    <script src="/js/ajaxupload.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jquery.form.min.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lims/js/common.js?v=20190726" type="text/javascript" charset="utf-8"></script>
    <style>
        html, body {
            width: 99%;
            height: 99%;
        }

        .layui-tab {
            height: 98%;
        }

        .layui-tab-content {
            height: calc(100% - 50px)
        }

        .layui-tab-item, .layui-card {
            height: 100%;
        }
    </style>

</head>
<body style="background-color: white;padding: 5px">
<div class="layui-tab">
    <ul class="layui-tab-title">
        <li class="layui-this">问答题批阅</li>

    </ul>
    <div class="layui-tab-content">

        <div class="layui-tab-item layui-show">
            <%--<div class="layui-form-item">--%>
            <%--<div class="layui-inline">--%>
            <%--<label class="layui-form-label">人员名称</label>--%>
            <%--<div class="layui-input-inline">--%>
            <%--<input name="signupUser" class="layui-input" type="text" id="signupUser">--%>
            <%--</div>--%>
            <%--<label class="layui-form-label">课程名称</label>--%>
            <%--<div class="layui-input-inline">--%>
            <%--<input name="signupUser" class="layui-input" type="text" id="signupCourse"--%>
            <%--autocomplete="off">--%>
            <%--</div>--%>
            <%--<button class="layui-btn" type="button" style="margin-left: 0px" id="searchButton2">搜索</button>--%>
            <%--<button class="layui-btn import" type="button" download="/file/jdProject/报名信息模板.xlsx" url="/signUp/importSignUp" style="margin-left: 0px"  id="import0">导入</button>--%>
            <%--</div>--%>
            <%--</div>--%>

            <table id="Settlement1" lay-filter="SettlementFilter1"></table>

        </div>

    </div>
</div>

<script type="text/html" id="barOperation">
    <a class="layui-btn layui-btn-xs"  lay-event="exam" id="exam">批阅</a>




</script>
<script type="text/javascript">
    layui.use('element', function () {
        var $ = layui.jquery
            , element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块

        //触发事件
        var active = {
            tabAdd: function () {
                //新增一个Tab项
                element.tabAdd('demo', {
                    title: '新选项' + (Math.random() * 1000 | 0) //用于演示
                    , content: '内容' + (Math.random() * 1000 | 0)
                    , id: new Date().getTime() //实际使用一般是规定好的id，这里以时间戳模拟下
                })
            }
            , tabDelete: function (othis) {
                //删除指定Tab项
                element.tabDelete('demo', '44'); //删除：“商品管理”


                othis.addClass('layui-btn-disabled');
            }
            , tabChange: function () {
                //切换到指定Tab项
                element.tabChange('demo', '22'); //切换到：用户管理
            }
        };

        $('.site-demo-active').on('click', function () {
            var othis = $(this), type = othis.data('type');
            active[type] ? active[type].call(this, othis) : '';
        });

        //Hash地址的定位
        var layid = location.hash.replace(/^#test=/, '');
        element.tabChange('test', layid);

        element.on('tab(test)', function (elem) {
            location.hash = 'test=' + $(this).attr('lay-id');
        });

    });
    var first;
    var sencond;
    layui.use(['laydate', 'laypage', 'layer', 'table', 'carousel', 'upload', 'element', 'slider'], function () {
        var laydate = layui.laydate //日期
            , laypage = layui.laypage //分页
            , layer = layui.layer //弹层
            , table = layui.table //表格
            , carousel = layui.carousel //轮播
            , upload = layui.upload //上传
            , element = layui.element //元素操作
            , slider = layui.slider //滑块
        //执行一个 table 实例
        table1 = table.render({
            elem: '#Settlement1'
            , url: '/exaExamination/selectQuestions5' //数据接口
            , title: '报名信息表'
            ,defaultToolbar: ['filter', {
                title: '提示' //标题
                ,layEvent: 'LAYTABLE_TIPS' //事件名，用于 toolbar 事件中使用
                ,icon: 'layui-icon-tips' //图标类名
            }]
            , page: true //开启分页
            , toolbar: 'default ' //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
            , cols: [[ //表头
                {field: 'signupId', title: 'ID', sort: true, fixed: 'left', hide: true}
                , {field: 'pName', title: '试卷名称'}
                , {field: 'userName', title: ' 姓名'}
                // , {field: 'courseStageName', title: '课程阶段'}
                // , {field: 'countScores', title: '总分'}
                ,{fixed: 'right',width:200, title: '操作',align:'center', toolbar: '#barOperation'}
            ]]
        });
        table.on('tool(SettlementFilter1)', function(obj){//注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象
            var signupId= data.signupId;
            var urlTitle='/course';
            if(layEvent === 'exam'){

//                $.layerMsg({content:'正在对接中',icon:6})
                window.open("/tbExamList/review?scoreId="+data.scoreId)
                // layer.confirm('正在对接中', {
                //     btn: ['确定','取消'], //按钮
                //     title:'考试'
                // }, function(){
                //   layer.closeAll()
                //
                // });
            }else if(layEvent === 'grade'){
                window.open("/tbExamList/testPaperExa?pId="+obj.data.pId)

            }
        });
        $("#searchButton1").click(function () {
            first = $("#signinUser").val();
            sencond = $("#signinCourse").val();
            table.reload('Settlement', {
                url: "/signIn/showAll",
                where: {
                    signinUser: first,
                    signinCourse: sencond
                }
            });


        })
        $("#searchButton2").click(function () {
            first = $("#signupUser").val();
            sencond = $("#signupCourse").val();
            table.reload('Settlement1', {
                url: "/signUp/showAll",
                where: {
                    signupUser: first,
                    signupCourse: sencond
                }
            });


        })
        $("#searchButton3").click(function () {
            first = $("#evaluateUser").val();
            sencond = $("#evaluateCourse").val();
            table.reload('Settlement2', {
                url: "/evaluate/showAll",
                where: {
                    evaluateUser: first,
                    evaluateCourse: sencond
                }
            });


        })


        $('.import').click(function() {
            var url = $(this).attr('url');
            var download = $(this).attr('download');

            layer.open({
                type: 1,
                skin: 'layui-layer-rim', //加上边框
                area: ['500px', '300px'], //宽高
                title: '导入',
                maxmin: true,
                btn: ['<div style="background:none;border:none;color:#fff" id="lay-submit">确定</div>', '取消'],
                content:jQuery("#opens"),
                yes:function(index){
                    if ($('input[name="file"]').val() == "") {
                        layer.msg("请选择要导入的文件！", {icon: 2});
                        return false;
                    }
                    var body = layer.getChildFrame('body', index);
                    var formData = new FormData();
                    formData.append("file",document.getElementById("file").files[0]);
                    $.ajax({
                        url:url,
                        dataType: 'json',
                        type: 'POST',
                        data: formData,
                        cache: false,
                        processData: false,  // 不处理数据
                        contentType: false,
                        success: function(r){
                            if(r.flag == 0){
                                alert("导入成功！");
                                vm.reload();

                            }else{
                                alert(r.msg);
                            }
                        }
                    });
                    layer.close(index);

                }
            })
        })
    });


</script>

</body>


</html>